package com.ut.demo.slice;

import com.thedazzler.droidicon.badges.DroidiconBadge;
import com.thedazzler.droidicon.factory.PixelMapFactory;
import com.ut.demo.ResourceTable;
import com.ut.demo.util.Utils;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Image;

public class MainAbilitySlice extends AbilitySlice {

    private DroidiconBadge bug,map,moon,card;

    private Image image_a,image_b,image_c,image_d,image_e;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        bug = findComponent(ResourceTable.Id_bug);
        map = findComponent(ResourceTable.Id_map);
        moon = findComponent(ResourceTable.Id_moon);
        card = findComponent(ResourceTable.Id_card);
        bug.setResId(ResourceTable.Media_fa_bug).setIconColor(0x7EFFFFFF).setBackgroundColor(0xFF2ecc71).setIconPadding(90).showCircularBadge(true).invalidate();
        map.setResId(ResourceTable.Media_entypo_map).setIconColor(0x7e1abc9c).setBackgroundColor(0xff2c3e50).setIconPadding(90).showCircularBadge(true).invalidate();
        moon.setResId(ResourceTable.Media_entypo_moon).setIconColor(0x9e000000).setBackgroundColor(0xffC92228).setIconPadding(90).showCircularBadge(true).invalidate();
        card.setResId(ResourceTable.Media_entypo_credit_card).setIconColor(0x7effffff).setBackgroundColor(0xFF9b59b6).setIconPadding(90).showCircularBadge(true).invalidate();

        image_a = findComponent(ResourceTable.Id_image_a);
        image_b = findComponent(ResourceTable.Id_image_b);
        image_c = findComponent(ResourceTable.Id_image_c);
        image_d = findComponent(ResourceTable.Id_image_d);
        image_e = findComponent(ResourceTable.Id_image_e);
        image_a.setPixelMap(PixelMapFactory.CreatePixelMap(this, ResourceTable.Media_iconic_article, Utils.randomColor()));
        image_b.setPixelMap(PixelMapFactory.CreatePixelMap(this, ResourceTable.Media_esocial_facebook, Utils.randomColor()));
        image_c.setPixelMap(PixelMapFactory.CreatePixelMap(this, ResourceTable.Media_esocial_spotify, Utils.randomColor()));
        image_d.setPixelMap(PixelMapFactory.CreatePixelMap(this, ResourceTable.Media_esocial_instagram, Utils.randomColor()));
        image_e.setPixelMap(PixelMapFactory.CreatePixelMap(this, ResourceTable.Media_meteo_sun, 0xFFFF3300));

    }



    private <T> T findComponent(int id){
        return (T)findComponentById(id);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
